﻿<!DOCTYPE HTML>
<html lang="zh-CN">
<head>
    <!--作为公共模版分离出去-->
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="Bookmark" href="admin/images/rookieCs.ico" />
    <link rel="Shortcut Icon" href="admin/images/rookieCs.ico" />
    <link rel="stylesheet" type="text/css" href="admin/static/h-ui/css/H-ui.my.css" />
    <link rel="stylesheet" type="text/css" href="admin/static/h-ui.admin.pro.iframe/css/h-ui.admin.pro.iframe.min.css" />
    <link rel="stylesheet" type="text/css" href="admin/lib/Hui-iconfont/1.0.9/iconfont.css" />
    <link rel="stylesheet" type="text/css" href="admin/static/h-ui.admin.pro.iframe/skin/default/skin.css" id="skin" />
    <link rel="stylesheet" type="text/css" href="admin/lib/jquery-easyui/1.7.0/themes/default/easyui.css" />
    <link rel="stylesheet" type="text/css" href="admin/lib/jquery-easyui/1.7.0/themes/icon.css" />
    <link rel="stylesheet" type="text/css" href="admin/lib/lc_switch/20160127/css/lc_switch.css" />
    <link rel="stylesheet" type="text/css" href="admin/css/iconfont/iconfont.css" />
    <link rel="stylesheet" type="text/css" href="admin/css/mywork.css" />
    <script type="text/javascript" src="admin/lib/jquery/1.9.1/jquery.min.js"></script>
    <script type="text/javascript" src="admin/lib/layer/3.1.1/layer.js"></script>
    <script type="text/javascript" src="admin/lib/jquery-easyui/1.7.0/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="admin/lib/jquery-easyui/1.7.0/plugins/datagrid-detailview.js"></script>
    <script type="text/javascript" src="admin/lib/jquery-easyui/1.7.0/locale/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript" src="admin/lib/lc_switch/20160127/js/lc_switch.min.js"></script>
    <script>document.write('<script type="text/javascript" src="admin/js/common.js?v='+ Date.now() +'"><\/script>');</script>
    <script>document.write('<script type="text/javascript" src="admin/js/formatter.js?v='+ Date.now() +'"><\/script>');</script>
    <!--作为公共模版分离出去-->
    <title>公众号类别列表</title>
</head>
<body class="easyui-layout" style="width: 100%; height: 100%;font-family: 微软雅黑,serif" memuId="mediumLabel-list">
<nav class="breadcrumb">
    <i class="Hui-iconfont">&#xe67f;</i> 首页
    <span class="c-gray en" style="float: none">&gt;</span> 公众号管理
    <span class="c-gray en" style="float: none">&gt;</span> 公众号类别管理
    <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a>
</nav>
<div data-options="region:'center', border:false">
    <!--按钮元素-->
    <div id="buttonInfo" style="padding: 2px 0px 2px 5px; background-color: #F5FAFE;">
        <button class="easyui-linkbutton" onclick="query(pageParam, true)"><i class="Hui-iconfont">&#xe665;</i>查询</button>
        <button class="easyui-linkbutton" onclick="addMediumLabel()"><i class="Hui-iconfont">&#xe600;</i>新增</button>
        <button class="easyui-linkbutton" onclick="delMediumLabel()"><i class="Hui-iconfont">&#xe6e2;</i>删除</button>
    </div>
    <!--表格元素-->
    <div id="tableInfo"></div>
</div>
<div data-options="region:'east', title:'查询条件', hideCollapsedContent:false, collapsible:true, collapsed:true" style="width:250px">
    <!--查询条件元素-->
    <form id="searchFormInfo">
        <div class="searchLabel">类别名称：<input id="s_labelName" name="labelName"/></div>
        <a id="searchBtn" onclick="query(pageParam, true)"></a>
    </form>
</div>
<script type="text/javascript">
    //准备函数
    $(function () {
        initGrid();
        initSearchForm();
        getGridHidden("tableInfo");
        query(pageParam);
    });

    //查询条件初始化
    function initSearchForm() {
        $("#s_labelName").textbox({
            width: 150
        });
    }

    //表格元素初始化
    function initGrid() {
        $("#tableInfo").datagrid({
            pagination: true,
            singleSelect: false,
            fitColumns: true,
            striped: true,
            fit: true,
            columns: [[
                {field: "ck", checkbox: "true"},
                {field: "id", title: "编号", width: 60, align: "center", sortable: true},
                {field: "labelName", title: "类别名称", width: 100, align: "center", sortable: true}
            ]],
            //表格工具栏元素ID
            toolbar: ".breadcrumb, #buttonInfo, #searchInfo",
            onSortColumn: function (orderBy, sortBy) {
                pageParam.pageNo = 1;
                pageParam.orderBy = orderBy;
                pageParam.sortBy = sortBy;
                query(pageParam);
            },
            onSelect: function() {
                selectedTableRow();
            },
            onUnselect: function() {
                selectedTableRow();
            },
            onSelectAll: function() {
                selectedTableRow();
            },
            onUnselectAll: function() {
                selectedTableRow();
            },
            onLoadSuccess: function () {
                toolBarBtnDisabledById([false, false, true], "buttonInfo");
            }
        }).pagination({
            total: 0,
            rows: 0,
            pageNumber: pageParam.pageNo,
            pageSize: pageParam.pageSize,
            pageList: Page.getPageList(),
            buttons: [
                {text: "个性化设置", iconCls: "icon-tip", handler: function() {selectColumnMenu("tableInfo");}}
            ],
            onBeforeRefresh : function() {},
            onSelectPage: function(pageNumber, pageSize) {
                pageParam.pageNo = pageNumber;
                pageParam.pageSize = pageSize;
                query(pageParam);
            },
            onChangePageSize: function(pageSize) {
                pageParam.pageSize = pageSize;
            }
        });
        //表格事件
        var selectedTableRow = function() {
            var selectRow = $("#tableInfo").datagrid("getSelections");
            if (selectRow.length === 0) {
                toolBarBtnDisabledById([false, false, true], "buttonInfo");
            } else if (selectRow.length === 1) {
                toolBarBtnDisabledById([false, false, false], "buttonInfo");
            } else {
                toolBarBtnDisabledById([false, false, false], "buttonInfo");
            }
        };
    }

    //分页查询
    function query(pageParam, goHead) {
        pageParam.condition = getFormJson($("#searchFormInfo"));
        pageParam.condition.type = 1;
        if (goHead && goHead)
            pageParam.pageNo = 1;
        ajaxGetFun("medium/queryMediumLabelPage", pageParam, function(bizData) {
            $("#tableInfo").datagrid("loadData", bizData.rowList);
            $("#tableInfo").datagrid("getPager").pagination({pageNumber: bizData.pageNo, total: bizData.total});
        }, null, "获取公众号类别列表");
    }

    //新增
    function addMediumLabel() {
        openIframe(false, 500, 100, "medium-label-info.html", function() {}, function(index, layero) {
            var formEle = layero.find("iframe")[0].contentWindow.$("#formInfo");
            if (formEle.form("validate")) {
                var mediumLabelInfo = getFormJson(formEle);
                mediumLabelInfo.type = 1;
                ajaxPostFun("medium/saveMediumLabelInfo", mediumLabelInfo, function() {
                    layer.close(index);
                    query(pageParam, true);
                    showSuccessMsg("新增成功");
                }, null, "新建公众号类别");
            }
        });
    }

    //删除
    function delMediumLabel() {
        var selectRows = $("#tableInfo").datagrid("getSelections");
        if (selectRows.length === 0) {
            return showWarnMsg("请选择条目后操作");
        }
        layer.confirm("确认要删除选中的公众号类别吗？", function() {
            ajaxPostFun("medium/deleteMediumLabelInfoByIds", {ids: mergedRowCell(selectRows, "id")}, function(bizData) {
                showSuccessMsg("已删除"+ bizData +"条数据");
                query(pageParam, true);
            }, null, "删除公众号类别");
        });
    }
</script> 
</body>
</html>